package org.grow.swimming.service;

import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Random;

/**
 * @Author: xwg
 * @CreateDate: 2022/5/7
 */

@Service
public class CodeGenerator {
    private Random random = new Random();

    public String nextCode(String prefix) {
        Integer r = random.nextInt(8999) + 1000;
        String s = LocalDateTime.now().format(DateTimeFormatter.ofPattern("MMddHHmmss"));
        return prefix + r + s;
    }
}
